home *** CD-ROM | disk | FTP | other *** search
/ Linux Cubed Series 2: Applications / Linux Cubed Series 2 - Applications.iso / circuits / ocean / cacd_bin.000 / cacd_bin / lib / epslay.pro < prev    next >
Text File  |  1993-06-08  |  13KB  |  473 lines

  1. % SccsId @(#)epslay.pro 4.3 (TU-Delft) 8/27/92
  2. %
  3. % Author: N.P. van der Meijs.
  4. %
  5. % This is the common part of the eps prolog for getepslay,
  6. % the process-specific part is still to be added.
  7. % This is to be done with %%Include directive of getepslay.
  8.  
  9. /fillBigPaths {/bigPathFill exch def} def
  10.  
  11.   true  fillBigPaths   % Goes well if poly has no holes.
  12. % false fillBigPaths   % Uncomment this line if poly has holes that are
  13.                % plotted incorrectly. The result is that the masks
  14.                % that contain such polygons are not filled
  15.                % (contour only), but the layout is otherwise
  16.                % plotted normally.
  17.  
  18. % Assumes three pass plotting:
  19. % pass 1: filled mask layers
  20. % pass 2: contour of mask layers, and other stroked paths
  21. % pass 3: text, so it is on top of everyting.
  22.  
  23. /EPSLayDict 140 dict def EPSLayDict begin
  24. /Style 40 dict def
  25. 0 setlinewidth
  26.  
  27. % The following has to do with pathLimit of (Level 1) Postscript.
  28. /pathCount 0 def
  29. /pathLimit 1000 def
  30. /pathLimitExceeded false def
  31.  
  32. % First, some procedure definitions for defining overal appearance,
  33. % and setting of defaults.
  34.  
  35. % [min max lambda fontname] plotFont -
  36. /plotFont {
  37.     aload pop
  38.     /FontName exch def
  39.     /LambdaFs exch def
  40.     /MaxFs    exch def
  41.     /MinFs    exch def
  42.     % [(FontName) FontName (LambdaFs) LambdaFs (MaxFs) MaxFs (MinFs) MinFs] ==
  43.     % /FontSize MinFs def % avoid use before define
  44. } def
  45. [8 8 1 /Helvetica-Bold] plotFont % default 8 point non-proportional
  46.  
  47. % [factor] plotPatScale -
  48. /patternScale {aload pop /Bfreq exch def} def
  49. [1] patternScale % default
  50.  
  51. % bool plotRotate
  52. /plotRotate {/Rotate exch def} def
  53. false plotRotate % default
  54.  
  55. % Defaults
  56. /Tailwd    1 def % width of arrow tails, in points
  57. /Tipwd     6 def % width of arrow heads, in points
  58.  
  59. /plotPass {/passnumber exch def} def
  60. 1 plotPass
  61.  
  62. % Drawing patterns.
  63. %
  64. /basketweave  [1 8 <d1e3c5885c3e1d88>] def
  65. /fishscale    [1 8 <3e418080e3140808>] def
  66.  
  67. /p2 [2 16 <1010200840048002000100000000000010100820044002800100000000000000>]
  68. def
  69. /p4 [2 16 <18000c00040000000004000c00180030006000c0008000008000c00060003000>]
  70. def
  71. /p5 [2 16 <c071c00101e001e001e0e001e001e3c103c003c0000f1c0f1c0f1c000070c071>]
  72. def
  73. /p6 [2 16 <1000001000000200000040000008010000000000100200000000004000000001>]
  74. def
  75. /p7 [2 16 <002100210021ffe1e1e1e1e1e1ffe1ff210021002100e1ffe1e1e1e1ffe1ffe1>]
  76. def
  77. /p8 [2 16 <0000000080c0c0c160033006180c0c1806300360c1c0c08000000000cccccccc>]
  78. def
  79. /p9 [2 16 <00000000c0c0c0c00000000000c000c000000000cccccccc0000000000c000c0>]
  80. def
  81. /p13 [2 16 <00ff00ff00ff00ff00ff00ff00ff00ffff00ff00ff00ff00ff00ff00ff00ff00>]
  82. def
  83. /p15 [2 16 <ffff0202040408081010202040408080ffff4040202010100808040402020101>]
  84. def
  85. /p16 [2 16 <4040202010100808040402020101808040402020101008080404020201018080>]
  86. def
  87. /p17 [2 16 <c0c06060303018180c0c060603038181c0c06060303018180c0c060603038181>]
  88. def
  89. /p18 [2 16 <0180024004200810100820044002800180014002200410080810042002400180>]
  90. def
  91. /p19 [2 16 <8080808080808080808080808080808080808080808080808080808080808080>]
  92. def
  93.  
  94. /lines0    [1 8 <ff000000ff000000>] def % lines 0 degrees inclined (horiz)
  95. /lines45   [1 8 <0102040810204080>] def % lines 45 degrees inclined (/)
  96. /lines90   [1 8 <1111111111111111>] def % lines 90 degrees inclined (vert)
  97. /lines135  [1 8 <8040201008040201>] def % lines 135 degrees inclined (\)
  98. /flines0   [1 8 <ffff000000000000>] def % fat lines 0 dg. inclined (horiz)
  99. /flines45  [1 8 <03060C183060C081>] def % fat lines 45 dg. inclined (/)
  100. /flines90  [1 8 <3333333333333333>] def % fat lines 90 dg. inclined (vert)
  101. /flines135 [1 8 <81C06030180C0603>] def % fat lines 135 dg. inclined (\)
  102. /cross0    [1 8 <ff01010101010101>] def % lines 0 and 90
  103. /cross45   [1 8 <110a040a11a040a0>] def % lines 45 and 135
  104. /fcross45  [1 8 <331e0c1e33e1c0e1>] def % lines 45 and 135
  105. /black     [1 8 <ffffffffffffffff>] def % black (or dots 100%)
  106. /dots50    [1 8 <aa55aa55aa55aa55>] def % dots 50%
  107. /dots25    [1 8 <8822882288228822>] def % dots 25%
  108. /dots12    [1 8 <8800220088002200>] def % dots ~12% (1 of 8)
  109. /dots6     [1 8 <8800000088000000>] def % dots ~ 6% (1 of 16)
  110. /dots3     [1 8 <8000000080000000>] def % dots ~ 3% (1 of 32)
  111. /dots2     [1 8 <8000000000000000>] def % dots ~ 2% (1 of 64)
  112. /white     [1 8 <0000000000000000>] def % white (or dots 0%)
  113.  
  114. /bitison {
  115.     /ybit exch def /xbit exch def
  116.     bstring ybit bwidth mul
  117.     xbit 8 idiv add get
  118.     1 7 xbit 8 mod sub bitshift
  119.     and 0 ne
  120. } def
  121.  
  122. /setpattern {
  123.     /bstring exch def
  124.     /onbits 0 def /offbits 0 def
  125.     freq 0 {
  126.       /y exch def /x exch def
  127.       /xindex x 1 add 2 div bpside mul cvi def
  128.       /yindex y 1 add 2 div bpside mul cvi def
  129.       xindex yindex bitison
  130.         {/onbits onbits 1 add def 1}
  131.         {/offbits offbits 1 add def 0}
  132.         ifelse
  133.     } setscreen
  134.     {} settransfer
  135.     offbits offbits onbits add div setgray
  136. } def
  137.  
  138. % Adapted from cookbook example program.
  139. % x1 y1 x2 y2 Tailwd headwd headlen type arrow
  140. /arrow {
  141.     0 begin
  142.     /ArrowType exch def 
  143.     /headlength exch def
  144.     /halfheadthickness exch 2 div def
  145.     /halfthickness exch 2 div def
  146.     /tipy exch def /tipx exch def
  147.     /taily exch def /tailx exch def
  148.     /dx tipx tailx sub def
  149.     /dy tipy taily sub def
  150.     /arrowlength dx dx mul dy dy mul add sqrt def
  151.     /angle dy dx atan def
  152.     /base arrowlength headlength sub def
  153.                                                             
  154.     /savematrix matrix currentmatrix def
  155.     tailx taily translate
  156.     angle rotate
  157.  
  158.     /Forward false def
  159.     /Backward false def
  160.     ArrowType 1 eq {/Forward  true def} if
  161.     ArrowType 3 eq {/Forward  true def} if
  162.     ArrowType 2 eq {/Backward true def} if
  163.     ArrowType 3 eq {/Backward true def} if
  164.     0 0 moveto
  165.  
  166.     Backward {
  167.         headlength halfheadthickness neg lineto
  168.         headlength halfthickness neg lineto
  169.     } { 0 halfthickness neg lineto
  170.     } ifelse
  171.  
  172.     Forward {
  173.         base halfthickness neg lineto
  174.         base halfheadthickness neg lineto
  175.         arrowlength 0 lineto
  176.         base halfheadthickness lineto
  177.         base halfthickness lineto
  178.     } { arrowlength halfthickness neg lineto
  179.         arrowlength halfthickness lineto
  180.     } ifelse
  181.  
  182.     Backward {
  183.         headlength halfthickness lineto
  184.         headlength halfheadthickness lineto
  185.     } { 0 halfthickness lineto
  186.     } ifelse
  187.  
  188.     closepath savematrix setmatrix end
  189. } def
  190. /arrow load 0 16 dict put
  191.  
  192. % x y dx dy text Text -
  193. % Shows string with (dx,dy) relative to bounding box at (x,y)
  194. % Dx and dy work same as in mathematica
  195. % On white background.
  196. /Text {
  197.     0 begin
  198.     /text exch def
  199.     /dy exch def /dx exch def
  200.     /Y exch def /X exch def
  201.     text stringwidth pop /W exch def
  202.     /H FontSize def
  203.  
  204.     % center text
  205.     /Y Y FontSize 2 div sub def
  206.     /X X W 2 div sub def
  207.  
  208.     % adjust according to dx,dy
  209.     /X X dx W mul 2 div sub def
  210.     /Y Y dy H mul 2 div sub def
  211.  
  212.     gsave
  213.     % determine bbox of text.
  214.     newpath X Y moveto text true charpath pathbbox
  215.     /st exch def /sr exch def /sb exch def /sl exch def
  216.  
  217.     % define a margin around bbox of text
  218.     /Margin st sb sub 0.2 mul def
  219.     /sb sb Margin sub def
  220.     /sl sl Margin sub def
  221.     /sr sr Margin add def
  222.     /st st Margin add def
  223.  
  224.     % construct path corresponding to bbox
  225.     newpath sl sb moveto sr sb lineto sr st lineto sl st lineto
  226.     closepath
  227.  
  228.     % make it white.
  229.     gsave 1 setgray fill grestore
  230.  
  231.     % stroke outline
  232.     gsave 0 setlinewidth stroke grestore
  233.  
  234.     grestore
  235.  
  236.     % print text.
  237.     X Y moveto text show
  238.  
  239.     end
  240. } def
  241. /Text load 0 20 dict put
  242.  
  243. /BeginLayout {
  244.     /EPSLayGC save def
  245.     /TForm exch def % TForm ==
  246.  
  247.     /bbxl TForm 4 get def
  248.     /bbxr TForm 6 get def
  249.     /bbyb TForm 5 get def
  250.     /bbyt TForm 7 get def
  251.     /Resolution TForm 8 get def
  252.  
  253.     % Rotate if necessary
  254.     Rotate {
  255.         /xl TForm 7 get neg def
  256.         /xr TForm 5 get neg def
  257.         /yb TForm 4 get def
  258.         /yt TForm 6 get def
  259.  
  260.         TForm 4 xl put
  261.         TForm 6 xr put
  262.         TForm 5 yb put
  263.         TForm 7 yt put
  264.     } if % TForm ==
  265.  
  266.     /DrawWd TForm 2 get TForm 0 get sub def
  267.     /DrawHt TForm 3 get TForm 1 get sub def
  268.  
  269.     /PicHt TForm 7 get TForm 5 get sub def
  270.     /PicWd TForm 6 get TForm 4 get sub def   
  271.  
  272.     /WdScale DrawWd PicWd div def
  273.     /HtScale DrawHt PicHt div def
  274.  
  275.     /ScaleFactor
  276.         WdScale HtScale lt {WdScale} {HtScale} ifelse def
  277.  
  278.     % now move to center
  279.     TForm 0 get DrawWd PicWd ScaleFactor mul sub 2 div add
  280.     TForm 1 get DrawHt PicHt ScaleFactor mul sub 2 div add
  281.     translate
  282.  
  283.     % Finally, perform scaling.  [(ScaleFactor) ScaleFactor] ==
  284.     ScaleFactor ScaleFactor scale
  285.  
  286.     % but following items should not be scaled, so undo it.
  287.     /Tailwd Tailwd ScaleFactor div def
  288.     /Tipwd Tipwd ScaleFactor div def
  289.  
  290.     % Compute {min,max}fontsize and target fontsize in scaled coordinates.
  291.     /MinFs MinFs ScaleFactor div def
  292.     /MaxFs MaxFs ScaleFactor div def
  293.     /FontSize LambdaFs Resolution mul def
  294.     % [MinFs MaxFs FontSize] ==
  295.  
  296.     % Apply min and max, and set font
  297.     FontSize MinFs lt {/FontSize MinFs def} if
  298.     FontSize MaxFs gt {/FontSize MaxFs def} if
  299.     FontName findfont FontSize scalefont setfont
  300.  
  301.     % set user origin
  302.     TForm 4 get neg TForm 5 get neg translate
  303.     Rotate {90 rotate} if
  304. } def
  305.  
  306. /SetClipPath {
  307.     newpath
  308.     bbxl bbyb moveto
  309.     bbxr bbyb lineto
  310.     bbxr bbyt lineto
  311.     bbxl bbyt lineto
  312.     closepath
  313.     clip
  314. } def
  315.  
  316. /SetLayer {
  317.     /Layer exch def
  318.     gsave
  319.     passnumber 1 eq {SetClipPath} if
  320.     SetStyle clear newpath
  321.     /pathLimitExceeded false def
  322. } def
  323.  
  324. /EndLayer {
  325.     pathCount 0 gt {DrawPolygons} if
  326.     grestore
  327. } def
  328.  
  329. % Start a polygon: x0 y0 P -
  330. /P {moveto /pathCount pathCount 1 add def} def
  331.  
  332. % Continue a polygon: x y T -
  333. /T {lineto /pathCount pathCount 1 add def} def
  334.  
  335. % Close a polygon: x y L -
  336. /L {
  337.     T closepath
  338.     pathCount pathLimit gt {
  339.     /pathLimitExceeded true def DrawPolygons
  340.     } if
  341. } def
  342.  
  343. % Rectangular box: x0 y0 w h B -
  344. /B {
  345.     /dy exch def /dx exch def /yb exch def /xl exch def
  346.     /xr xl dx add def
  347.     /yt yb dy add def
  348.     xl yb P xr yb T xr yt T xl yt L
  349. } def
  350.  
  351. /R {
  352.     /dy exch def /dx exch def /y0 exch def /x0 exch def
  353.     x0 y0 P dx 0 rlineto 0 dy rlineto
  354.     /pathCount pathCount 2 add def
  355. } def
  356.  
  357. /X {
  358.     exch 0 rlineto 0 exch rlineto
  359.     /pathCount pathCount 2 add def
  360. } def
  361.  
  362. /C {
  363.     exch 0 rlineto 0 exch rlineto
  364.     % [(current) currentpoint (x0) x0 (y0) y0 ] ==
  365.     x0 currentpoint pop sub 0 rlineto
  366.     closepath
  367.     /pathCount pathCount 4 add def
  368.     pathCount pathLimit gt {
  369.     /pathLimitExceeded true def DrawPolygons
  370.     } if
  371. } def
  372.  
  373. /EndLayout {
  374.     EndLayer showpage
  375.     % EPSLayDict length =
  376.     EPSLayGC restore
  377.     end
  378. } def
  379.  
  380. /DrawPolygons {
  381.     % pathLimitExceeded { [(pathLimitExceeded) pathCount Layer] == } if
  382.     passnumber 1 eq {
  383.     pathLimitExceeded false eq bigPathFill true eq or {
  384.         gsave FillPolygons grestore
  385.     } if
  386.     } if
  387.     % Always stroke polygon boundaries, because a mask
  388.     % might be skipped in pass 2.
  389.     OutlinePolygons 
  390.     /pathCount 0 def
  391. } def
  392.  
  393. /FillPolygons {FillPattern setpattern fill} def
  394.  
  395. /OutlinePolygons {
  396.     /bwidth 1    def
  397.     /bpside 8    def
  398.     <ffffffffffffffff> setpattern
  399.     LineWd setlinewidth
  400.     0 setgray
  401.     stroke
  402. } def
  403.  
  404. /SetStyle {
  405.     Style Layer get aload pop
  406.     /LineWd exch Resolution mul def % in lambda's
  407.     /Pfreq exch def
  408.     aload pop
  409.     /FillPattern exch def
  410.     /bpside exch def
  411.     /bwidth exch def
  412.     /freq 300 bpside div Pfreq div Bfreq div def
  413.     % [(bpside, bwidth, freq) bpside bwidth freq (FillPattern) FillPattern]==
  414. } def
  415.  
  416. % x1 y1 x2 y2 ArrowType plotArrow
  417. % ArrowType has meaning as defined in dali/comment.h
  418. /plotArrow {
  419.     /ArrowType exch def
  420.     /y2 exch def
  421.     /x2 exch def
  422.     /y1 exch def
  423.     /x1 exch def
  424.     newpath
  425.     x1 y1 x2 y2 Tailwd Tipwd Tipwd 2 mul ArrowType arrow
  426.     fill
  427. } def
  428.  
  429. /align false def
  430. %[dx dy] termTextAlignment
  431. /termTextAlignment {
  432.     aload pop
  433.     /ady exch def
  434.     /adx exch def
  435.     /align true def
  436. } def
  437.  
  438. % xl xr yb yt dx dy termname plotTerminal
  439. /plotTerminal {
  440.     /name exch def
  441.     /dy exch def /dx exch def
  442.     /yt exch def /yb exch def /xr exch def /xl exch def
  443.     passnumber 2 eq {
  444.     LineWd setlinewidth
  445.     newpath
  446.     xl yb moveto xr yb lineto xr yt lineto xl yt lineto
  447.     closepath stroke
  448.     newpath xl yb moveto xr yt lineto stroke
  449.     newpath xr yb moveto xl yt lineto stroke
  450.     } if
  451.     passnumber 3 eq {
  452.     align true eq {/dx adx def /dy ady def} if
  453.         xl xr add 2 div yb yt add 2 div dx dy name Text
  454.     } if
  455. } def
  456.  
  457. /PlotBBox {
  458.     passnumber 2 eq {
  459.     1 setlinewidth newpath
  460.     bbxl bbyb moveto
  461.     bbxr bbyb lineto
  462.     bbxr bbyt lineto
  463.     bbxl bbyt lineto
  464.     closepath stroke
  465.     } if
  466. } def
  467.  
  468. % [ (maskname) pattern pfreq linewidth ] defineStyle -
  469. /defineStyle {
  470.     /stylearg exch def
  471.     Style stylearg 0 get stylearg 1 3 getinterval put
  472. } def
  473.